package com.zqxq.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
	/** 
	   * @param str 
	   * @return  
	   * @Description: 32位小写MD5 
	   */ 
	  public String doMD5(String param){ 
		  try
		    {
		      byte[] hash = MessageDigest.getInstance("MD5").digest(param.getBytes("UTF-8"));
		      StringBuilder localStringBuilder = new StringBuilder(hash.length * 2);
		      for (byte b : hash)
		      {
		        
		        if ((b & 0xFF) < 0x10) {
		          localStringBuilder.append("0");
		        }
		        localStringBuilder.append(Integer.toHexString(b & 0xFF));
		      }
		      
		      return localStringBuilder.toString();
		    }
		    catch (NoSuchAlgorithmException e)
		    {
		      e.printStackTrace();
		      return "";
		    }
		    catch (UnsupportedEncodingException e)
		    {
		      e.printStackTrace();
		      return "";
		    } 
	  }
}
